
using log4net.Config;
using log4net;
using Microsoft.Extensions.Logging;
using System.Configuration;
using System.Reflection;

namespace flyfire.whitelistAuthorization
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);
            builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var configuration = builder.Configuration;
            //Console.WriteLine("Logging Configuration:");
            //Console.WriteLine($"Default Log Level: {configuration["Logging:LogLevel:Default"]}");
            //Console.WriteLine($"Microsoft Log Level: {configuration["Logging:LogLevel:Microsoft"]}");

            // Add services to the container.
            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen();

            builder.Services.Configure<WhiteIpList>(configuration.GetSection("WhiteIpList"));

            builder.Logging.ClearProviders();
            //builder.Logging.AddConsole();
            builder.Logging.AddLog4Net("log4net.config");

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }

            app.UseAuthorization();
            app.MapControllers();

            app.Run();
        }
    }

    public class WhiteIpList
    {
        public List<string> IpList { get; set; }
    }
}
